ComponentOne Basic Library for UWP
Basic Library Overview / TreeView for UWP / TreeView for UWP Task-Based Help / Adding Check Boxes to the TreeView
In This Topic
    Adding Check Boxes to the TreeView
    In This Topic

    You can easily add check boxes to the C1TreeView control, check boxes can appear before text and allow users to select a tree view item. The following XAML markup adds check boxes to the C1TreeView:

    Markup
    Copy Code
    <Xaml:C1TreeView Name="C1TreeView1" Height="300" Width="200" >
        <Xaml:C1TreeViewItem IsExpanded="True" Margin="10">
            <Xaml:C1TreeViewItem.Header>
                <CheckBox>
                    <CheckBox.Content>
                        <TextBlock Text="Desktop" />
                    </CheckBox.Content>
                </CheckBox>
            </Xaml:C1TreeViewItem.Header>
        <Xaml:C1TreeViewItem>
            <Xaml:C1TreeViewItem.Header>
                <CheckBox>
                    <CheckBox.Content>
                        <TextBlock Text="User" />
                    </CheckBox.Content>
                </CheckBox>
            </Xaml:C1TreeViewItem.Header>
        </Xaml:C1TreeViewItem>
        <Xaml:C1TreeViewItem>
            <Xaml:C1TreeViewItem.Header>
                <CheckBox>
                    <CheckBox.Content>
                        <TextBlock Text="Public" />
                    </CheckBox.Content>
                </CheckBox>
            </Xaml:C1TreeViewItem.Header>
            <Xaml:C1TreeViewItem>
                <Xaml:C1TreeViewItem.Header>
                    <CheckBox>
                        <CheckBox.Content>
                        <TextBlock Text="Favorites" />
                        </CheckBox.Content>
                    </CheckBox>
                </Xaml:C1TreeViewItem.Header>
        </Xaml:C1TreeViewItem>
            <Xaml:C1TreeViewItem>
                <Xaml:C1TreeViewItem.Header>
                    <CheckBox>
                        <CheckBox.Content>
                        <TextBlock Text="Public Downloads" />
                        </CheckBox.Content>
                    </CheckBox>
                </Xaml:C1TreeViewItem.Header>
        </Xaml:C1TreeViewItem>
            <Xaml:C1TreeViewItem>
                <Xaml:C1TreeViewItem.Header>
                    <CheckBox>
                        <CheckBox.Content>
                        <TextBlock Text="Public Music" />
                        </CheckBox.Content>
                    </CheckBox>
                </Xaml:C1TreeViewItem.Header>
        </Xaml:C1TreeViewItem>
            <Xaml:C1TreeViewItem>
                <Xaml:C1TreeViewItem.Header>
                    <CheckBox>
                        <CheckBox.Content>
                        <TextBlock Text="Public Pictures" />
                        </CheckBox.Content>
                    </CheckBox>
                </Xaml:C1TreeViewItem.Header>
        </Xaml:C1TreeViewItem>
            <Xaml:C1TreeViewItem>
                <Xaml:C1TreeViewItem.Header>
                    <CheckBox>
                        <CheckBox.Content>
                        <TextBlock Text="Public Videos" />
                        </CheckBox.Content>
                    </CheckBox>
                </Xaml:C1TreeViewItem.Header>
        </Xaml:C1TreeViewItem>
                </Xaml:C1TreeViewItem>
                <Xaml:C1TreeViewItem IsExpanded="True">
            <Xaml:C1TreeViewItem.Header>
                <CheckBox>
                    <CheckBox.Content>
                        <TextBlock Text="Computer" />
                    </CheckBox.Content>
                </CheckBox>
            </Xaml:C1TreeViewItem.Header>
                    <Xaml:C1TreeViewItem IsExpanded="True">
                <Xaml:C1TreeViewItem.Header>
                    <CheckBox>
                        <CheckBox.Content>
                        <TextBlock Text="Local Disk (C:)" />
                        </CheckBox.Content>
                    </CheckBox>
                </Xaml:C1TreeViewItem.Header>
                <Xaml:C1TreeViewItem>
                    <Xaml:C1TreeViewItem.Header>
                        <CheckBox>
                            <CheckBox.Content>
                            <TextBlock Text="Program Files" />
                            </CheckBox.Content>
                        </CheckBox>
                    </Xaml:C1TreeViewItem.Header>
            </Xaml:C1TreeViewItem>
                <Xaml:C1TreeViewItem>
                    <Xaml:C1TreeViewItem.Header>
                        <CheckBox>
                            <CheckBox.Content>
                                <TextBlock Text="Users" />
                            </CheckBox.Content>
                        </CheckBox>
                    </Xaml:C1TreeViewItem.Header>
            </Xaml:C1TreeViewItem>
                <Xaml:C1TreeViewItem>
                    <Xaml:C1TreeViewItem.Header>
                        <CheckBox>
                            <CheckBox.Content>
                                <TextBlock Text="Windows" />
                            </CheckBox.Content>
                        </CheckBox>
                    </Xaml:C1TreeViewItem.Header>
            </Xaml:C1TreeViewItem>
        </Xaml:C1TreeViewItem>
            <Xaml:C1TreeViewItem>
                <Xaml:C1TreeViewItem.Header>
                    <CheckBox>
                        <CheckBox.Content>
                            <TextBlock Text="DVD Drive (D:)" />
                        </CheckBox.Content>
                    </CheckBox>
                </Xaml:C1TreeViewItem.Header>
            </Xaml:C1TreeViewItem>
        </Xaml:C1TreeViewItem>
        <Xaml:C1TreeViewItem>
            <Xaml:C1TreeViewItem.Header>
                <CheckBox>
                    <CheckBox.Content>
                        <TextBlock Text="Network" />
                    </CheckBox.Content>
                </CheckBox>
            </Xaml:C1TreeViewItem.Header>
                </Xaml:C1TreeViewItem>
        <Xaml:C1TreeViewItem>
            <Xaml:C1TreeViewItem.Header>
                <CheckBox>
                    <CheckBox.Content>
                        <TextBlock Text="Control Panel" />
                    </CheckBox.Content>
                </CheckBox>
            </Xaml:C1TreeViewItem.Header>
                </Xaml:C1TreeViewItem>
        <Xaml:C1TreeViewItem>
            <Xaml:C1TreeViewItem.Header>
                <CheckBox>
                    <CheckBox.Content>
                        <TextBlock Text="Recycle Bin" />
                    </CheckBox.Content>
                </CheckBox>
            </Xaml:C1TreeViewItem.Header>
            </Xaml:C1TreeViewItem>
        </Xaml:C1TreeViewItem>
    </Xaml:C1TreeView>
    
    See Also